package top.api.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

public enum CommonOrderPayStatusEnum {
    // 支付状态(未付款: 0 已付款: 1 已退款到余额: 2  已退款到微信: 3 关闭订单: 4)
    UNPAID(0,"未付款"),
    PAID(1,"已付款"),
    REFUNDEDMONEY(2,"退款余额"),
    REFUNDEDWX(3,"退款微信"),
    CLOSE(4,"关闭订单");

    @EnumValue
    @JsonValue
    private final int code;

    private final String status;

    CommonOrderPayStatusEnum(int code, String status) {
        this.code = code;
        this.status = status;
    }

    public int getCode() {
        return code;
    }

    public String getStatus() {
        return status;
    }

    public static CommonOrderPayStatusEnum getCommonPayStatusEnumByCode(int code) {
        for (CommonOrderPayStatusEnum commonPayStatusEnum : CommonOrderPayStatusEnum.values()) {
            if (commonPayStatusEnum.getCode() == code) {
                return commonPayStatusEnum;
            }
        }
        throw new RuntimeException("没有满足条件的枚举");
    }
}
